package com.demo.design02;

import com.alibaba.fastjson.JSON;

import java.util.Date;
import java.util.Map;

/**
 * @author ytj
 * @date 2022/2/21
 */
public class MQAdapter {

    public static RebateInfo filter(String strJson,Map<String,String> link) throws Exception{
        return filter(JSON.parseObject(strJson,Map.class),link);
    }

    public static RebateInfo filter(Map obj,Map<String,String> link) throws Exception{
        RebateInfo rebateInfo=new RebateInfo();
        for (String key : link.keySet()) {
            Object val=obj.get(link.get(key));
            String methodName="set"+key.substring(0,1).toUpperCase()+ key.substring(1);
            RebateInfo.class.getMethod(methodName,String.class).invoke(rebateInfo,val.toString());
        }
        return rebateInfo;
    }
}
